package com.stylefeng.symka.core.beetl;

import com.stylefeng.symka.common.constant.cookie.CookieKey;
import com.stylefeng.symka.core.cache.CacheKit;
import com.stylefeng.symka.core.util.CookieKit;
import com.stylefeng.symka.core.util.ToolUtil;
import org.springframework.context.i18n.LocaleContextHolder;

import java.util.Locale;

import static com.stylefeng.symka.common.constant.Const.CHINESE;
import static com.stylefeng.symka.common.constant.cache.Cache.I18N_CN;


public class I18n {

    public static String get(String object) {
        String value = CookieKit.get(CookieKey.LANG);
        if (ToolUtil.isNotEmpty(value)) {
            if(value.equals(CHINESE)){
                return CacheKit.get(I18N_CN, object);
            }else {
                return object;
            }
        } else {
            if (LocaleContextHolder.getLocale().equals(Locale.CHINA)) {
                //坐在地在中国
                return CacheKit.get(I18N_CN, object);
            } else {
                //坐在地不在中国
                return object;

            }
        }


    }


}
